home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / cawf404.zip / store.c < prev    next >
C/C++ Source or Header  |  1993-12-07  |  8KB  |  186 lines

  1. /*
  2.  *    store.c - cawf(1) storage areas
  3.  */
  4.  
  5. /*
  6.  *    Copyright (c) 1991 Purdue University Research Foundation,
  7.  *    West Lafayette, Indiana 47907.  All rights reserved.
  8.  *
  9.  *    Written by Victor A. Abell <abe@mace.cc.purdue.edu>,  Purdue
  10.  *    University Computing Center.  Not derived from licensed software;
  11.  *    derived from awf(1) by Henry Spencer of the University of Toronto.
  12.  *
  13.  *    Permission is granted to anyone to use this software for any
  14.  *    purpose on any computer system, and to alter it and redistribute
  15.  *    it freely, subject to the following restrictions:
  16.  *
  17.  *    1. The author is not responsible for any consequences of use of
  18.  *       this software, even if they arise from flaws in it.
  19.  *
  20.  *    2. The origin of this software must not be misrepresented, either
  21.  *       by explicit claim or by omission.  Credits must appear in the
  22.  *       documentation.
  23.  *
  24.  *    3. Altered versions must be plainly marked as such, and must not
  25.  *       be misrepresented as being the original software.  Credits must
  26.  *       appear in the documentation.
  27.  *
  28.  *    4. This notice may not be removed or altered.
  29.  */
  30.  
  31. #include "cawf.h"
  32.  
  33. struct rx Pat[] = {
  34.     { "^[.'](i[ef]|el)",                 NULL},    /* 0 */
  35.     { "^[.']i[ef] !",                NULL},  /* 1 */
  36.     { "^[.']i[ef] !?\\\\n\\(\\.\\$(>|>=|=|<|<=)[0-9] ",
  37.                             NULL},    /* 2 */
  38.     { "^[.']i[ef] !?'\\\\\\$[0-9]'[^']*' ",        NULL},    /* 3 */
  39.     { "^[.']i[ef] !?[nt] ",                NULL},  /* 4 */
  40.     { "\\\\\\$[0-9]",                               NULL},  /* 5 */
  41.     { "^[ \t]*$",                    NULL},  /* 6 */
  42.     { "\\\\|\t|-|  ",                NULL},    /* 7 */
  43.     { "[.!?:][]\\)'\\\"\\*]*$",                     NULL},  /* 8 */
  44.     { ",fP",                    NULL},    /* 9 */
  45.     { ",tP",                    NULL},    /* 10 */
  46.     { "^(ta|ll|ls|lt|in|ti|po|ne|sp|pl|nr)",        NULL},  /* 11 */
  47.     { "^(ll|ls|lt|in|ti|po|pl)",                    NULL},  /* 12 */
  48.     { "[]\\)'\\\"\\*]",                             NULL},  /* 13 */
  49.     { "^(LH|CH|RH|LF|CF|RF)",            NULL},    /* 14 */
  50.     { "^[.']i[ef]",                     NULL},    /* 15 */
  51.     { NULL,                                         NULL}   /* END */
  52. };
  53.  
  54. int Adj = BOTHADJ;            /* output line adjustment mode */
  55. unsigned char *Aftnxt = NULL;        /* action after next line */
  56. unsigned char *Args[] = { NULL, NULL,    /* 10 macro arguments */
  57.               NULL, NULL,
  58.               NULL, NULL,
  59.               NULL, NULL,
  60.               NULL, NULL
  61. };
  62. unsigned char *Argstack[10*MAXSP];    /* stack for Expand()'s "args[]" */
  63. int Backc = 0;                /* last word ended with '\\c' */
  64. int Botmarg = 5;            /* bottom margin */
  65. int Centering = 0;            /* centering count */
  66. int Condstack[MAXSP];                   /* stack for Expand()'s "cond" */
  67. unsigned char *Cont = NULL;        /* continue line append */
  68. int Contlen = 0;            /* continue line append length */
  69. int Curmx = -1;                /* current macro index */
  70. char *Device = NULL;            /* output device name */
  71. char *Devconf = NULL;            /* device configuration file path */
  72. char *Devfont = NULL;            /* output device font */
  73. int Divert = 0;                         /* diversion status */
  74. FILE *Efs = NULL;            /* error file stream */
  75. unsigned char *Eol = NULL;        /* end of line information */
  76. int Eollen = 0;                /* end of line length */
  77. int Err = 0;                            /* error flag */
  78. unsigned char *F = NULL;        /* field value */
  79. struct fcode Fcode[] = {        /* font codes */
  80.     { 'B',  '\0'},            /* Bold */
  81.     { 'I',  '\0'},            /* Italic */
  82.     { 'R',  '\0'},            /* Roman */
  83.     { '\0', '\0'}
  84. };
  85. int Fill = 0;                /* fill status */
  86. int Firstpg = 1;            /* fist page print status */
  87. unsigned char Font[] = { '\0', '\0' };    /* current font */
  88. int Fontctl;                /* output font control */
  89. char Fontstat = 'R';            /* output font status */
  90. int Fph = 0;                /* first page header status */
  91. int Fsp = 0;                /* files stack pointer (for .so) */
  92. struct fontstr Fstr;            /* font control strings */
  93. unsigned char *Ftc = NULL;        /* center footer */
  94. unsigned char *Ftl = NULL;        /* left footer */
  95. unsigned char *Ftr = NULL;        /* right footer */
  96. unsigned char *Hdc = NULL;        /* center header */
  97. int Hdft = 0;                /* header/footer status */
  98. unsigned char *Hdl = NULL;        /* left header */
  99. unsigned char *Hdr = NULL;        /* right header */
  100. struct hytab Hychar[MAXHYCH];        /* hyphen characters */
  101. FILE *Ifs = NULL;            /* input file stream */
  102. FILE *Ifs_stk[MAXFSTK];                 /* Ifs stack */
  103. int Ind = 0;                /* indentation amount */
  104. unsigned char *Inname = NULL;        /* input file name */
  105. unsigned char *Inn_stk[MAXFSTK];    /* Inname stack */
  106. int LL = DEFLLLT;            /* line length (default) */
  107. int LT = DEFLLLT;            /* 3 part title length (default) */
  108. unsigned char Line[MAXLINE];        /* input line */
  109. int Lockil = 0;                          /* pass 2 line number is locked
  110.                                          * (processing is inside macro) */
  111. int Marg = 0;                /* macro argument - man, ms, etc. */
  112. struct macro Macrotab[MAXMACRO];        /* macro table */
  113. unsigned char *Macrotxt[MAXMTXT];    /* macro text */
  114. int Mtx = 0;                            /* macro text index */
  115. int Mxstack[MAXSP];                     /* stack for Expand()'s "mx" */
  116. int Nfc;                /* number of font codes */
  117. int Nhnr[MAXNHNR];                      /* ".NH" numbers */
  118. int Nhy = 0;                /* number of Hychar[] entries */
  119. int Nleftstack[MAXSP];                  /* stack for Expand()'s "nleft" */
  120. int Nmac = 0;                           /* number of macros */
  121. int Nnr = 0;                /* number of Numb[] entries */
  122. int Nospmode = 1;                        /* no space mode */
  123. int NR = 0;                             /* number of record ala awk */
  124. int NR_stk[MAXFSTK];                       /* NR stack */
  125. int Nsch = 0;                /* number of Schar[] entries */
  126. int Nstr = 0;                /* number of entries in Str[] */
  127. int Ntabs = 0;                /* number of TAB positions */
  128. struct nbr Numb[MAXNR];            /* number registers */
  129. int Nxtln = 1;                /* next line number */
  130. int Outll = -1;                /* output line length */
  131. unsigned char Outln[MAXOLL*2];        /* output line */
  132. int Outlx = 0;                /* output line index */
  133. int P2il = 0;                             /* pass 2 input line number */
  134. unsigned char *P2name = NULL;        /* pass 2 input file name */
  135. int P3fill = 1;                /* pass 3 fill status */
  136. int Padchar[MAXOLL];            /* padding character locations */
  137. int Padfrom = PADLEFT;            /* which end to pad from */
  138. int Padx = 0;                /* Padchar[] index */
  139. struct parms Parms[] = {                /* parameter registers */
  140.     { {'i', 'n'}, "indent", 6, 0, 0        },
  141.     { {'l', 'l'}, "linelen", 7, DEFLLLT, 0    },
  142.     { {'l', 's'}, "vspace", 6, 1, 0        },
  143.     { {'l', 't'}, "ttllen", 6,DEFLLLT, 0    },
  144.     { {'t', 'i'}, "tempindent", 10, 0, 0    },
  145.     { {'p', 'o'}, "pageoffset", 10, 0, 0    },
  146.     { {'p', 'l'}, "pagelen", 7, DEFPGLEN, 0    },
  147.     { {'\0', '\0'}, NULL, 0, 0, 0        }
  148. };
  149. int Pageprt = 1;            /* page is to be printed */
  150. unsigned char Pass1ln[MAXLINE];        /* pass 1 output line */
  151. unsigned char Pass2ln[MAXLINE];        /* pass 2 output line */
  152. int Pglen = DEFPGLEN;            /* page length */
  153. int Pgoff = 0;                /* page offset */
  154. struct pgrange *PgRange = NULL;        /* page range structure chain */
  155. char *Pname = NULL;            /* program name */
  156. unsigned char Prevfont = '\0';        /* previous font */
  157. int Ptrstack[MAXSP];                    /* stack for Expand()'s "ptr" */
  158. struct scale Scale[] = {        /* scaling factors */
  159.     { 'i',    (240.0)             },
  160.     { 'c',    ((240.0 * 50.0)/127.0)    },
  161.     { 'P',    (240.0/6.0)        },
  162.     { 'p',    (240.0/72.0)        },
  163.     { 'u',  (1.0)                   },
  164.     { 'm',  (1.0)                   },
  165.     { 'n',  (1.0)                   },
  166.     { 'v',  (1.0)                   },
  167.     { '\0',    (0.0)            }
  168. };
  169. double Scalen = 0.0;            /* 'n' scaling factor */
  170. double Scaleu = 0.0;            /* 'u' scaling factor */
  171. double Scalev = 0.0;            /* 'v' scaling factor */
  172. struct schtab Schar[MAXSCH];        /* special characters */
  173. int Sp = -1;                /* stack pointer */
  174. struct str Str[MAXSTR];                 /* ".ds" strings */
  175. int Sx = -1;                /* string index */
  176. int Tabs[MAXEXP+1];            /* TAB positions */
  177. int Thispg = 1;                /* this page number */
  178. int Tind = 0;                 /* temporary indentation amount */
  179. int Topmarg = 5;            /* top margin */
  180. unsigned char *Trtbl = NULL;        /* .tr table */
  181. int Uhyph = 0;                /* hyphen usage state */
  182. int Vspace = 1;                /* vertical (inter-text-line) spacing */
  183. unsigned char Word[MAXLINE];        /* pass 2 word buffer */
  184. int Wordl = 0;